package com.example.tkserver.dao;

import com.example.tkserver.entity.SignIn;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface SignInHistoryDao {

    @Select("SELECT sid,uid,endorse,unix_timestamp(signInDatetime) datetime FROM signInHistory WHERE uid = #{uid} " +
            "AND FROM_UNIXTIME(unix_timestamp(NOW()),'%Y-%m-%d') = " +
            "FROM_UNIXTIME(unix_timestamp(signInDatetime),'%Y-%m-%d')")
    public SignIn getSignInByToday(int uid);

    @Insert("INSERT INTO signInHistory(uid,endorse,signInDatetime) VALUES(#{uid},#{endorse},NOW())")
    public int addNewSignInToday(int uid,int endorse);
}
